import { setToken, getToken, removeToken } from '@/utils/storage'

export default {
  state: {
    token: getToken(),
    username: ''
  },
  getters: {},
  mutations: {
    // user模块中封装存储token的  mutations函数
    setTokens(state, tokens) {
      state.token = tokens
      setToken(tokens)
    },
    // user模块中封装移除token的 mutations函数
    removeTokens(state) {
      state.token = {}
      // localStorage.removeItem('tokens')
      removeToken()
    },
    addUsername(state, name) {
      state.username = name
    }
  },
  actions: {},
  namespaced: true
}
